<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户注册</title>
<script type="text/javascript" src="js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript">
$(document).ready(function() { 
	var options = {
     beforeSubmit:  toSubmit,  // pre-submit callback
     success:       showResponse,  // post-submit callback
     dataType: 'json',
     //clearForm: true        // clear all form fields after successful submit
     //resetForm: true        // reset the form after successful submit
     timeout:   5000,
     error:	errorFun
 };
 $('#registerForm').ajaxForm(options);
}); 

function showResponse(responseText, statusText)  {
	changeImg();
	if(""!=responseText.msgs[0]){
		alert(responseText.msgs[0]);
	}
	
	if(responseText.isRedirect && ""!=responseText.redirect){
		window.location.href = responseText.redirect;
	}
}
function toSubmit(){
	
}
function errorFun(){
}

function changeImg(){
	$("#imgCode").attr("src",'<s:url action="vCode" namespace="/" />?r='+Math.random());
}
</script>
</head>
<body>
	<form id="registerForm" action='<s:url action="register" namespace="/" />' onsubmit="return toSubmit();" method="post">
	<table>
		<tr>
			<td>登录账号</td>
			<td>
				<input type="text" id="loginName" name="loginName" />
			</td>
		</tr>
		<tr>
			<td>登录密码</td>
			<td>
				<input type="password" id="loginPwd" name="loginPwd"/>
			</td>
		</tr>
		<tr>
			<td>确认密码</td>
			<td>
				<input type="password" id="loginPwd2" name="loginPwd2"/>
			</td>
		</tr>
		<tr>
			<td>电子邮箱</td>
			<td>
				<input type="text" id="email" name="email"/>
			</td>
		</tr>
		<tr>
			<td>验证码</td>
			<td>
				<input type="text" id="verifyCode" name="verifyCode" style="width: 80px;"/>&nbsp;<img id="imgCode" src="<s:url action="vCode" namespace="/" />" onclick="changeImg()" />
			</td>
		</tr>
		<tr>
			<td></td>
			<td>
				<input type="submit" name="注册"/>
			</td>
		</tr>
	</table>
	</form>
</body>
</html>